package com.gy.service;

import java.io.File;

import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class MonitorService {
	
	@Autowired
	private SqlSessionFactory sqlSessionFactory;
	
//	public void getmonitor()
//	{
//		SqlSession sqlSession = sqlSessionFactory.openSession();
//		MonitorMapper monitorMapper = sqlSession.getMapper(MonitorMapper.class);
//		
//	}
	public int monitorquantity(String roomname,String time)
	{
		String path = System.getProperty("evan.webapp");
		
//		SqlSession sqlSession = sqlSessionFactory.openSession();
//		RandM randm = sqlSession.getMapper(RandM.class);
		
		
		File file = new File(path+"monitor/"+roomname+"/"+time);
		int fileCount = 0;
		if (file != null && file.isDirectory()) {
			File[] fs = file.listFiles();
			for (int i = 0; i < fs.length; i++) {
				if (fs[i].isFile()) {
					fileCount++;
				}
			}
		}
		System.out.println(path+"monitor/"+roomname+"/"+time);
		return fileCount;
	}
}
